<template>
  <el-dialog
    v-el-drag-dialog
    :visible.sync="visible"
    width="500px"
    append-to-body
    @close="reset"
  >
    <div style="width: 100%;">
      <div class="title">您确定审核"{{ title }}"当前记录吗？</div>
      <!-- <el-input v-model="remark" type="textarea" :rows="3" maxlength="20" placeholder="请输入您需要的备注信息" /> -->
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="reset">取消</el-button>
      <el-button type="primary" @click="recovery">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import { callarAudit, returnAudit } from '@/api'

  export default {
    name: 'recovery',
    data() {
      return {
        visible: false,
        remark: '',
        title: ''
      }
    },
    methods: {
      async open(temp, title, aipType) {
        return new Promise(async(resolve) => {
          if (temp && title && aipType) {
            this.temp = temp
            this.title = title
            this.aipType = aipType
            this.resolve = resolve
            this.visible = true
          }
        })
      },
      async recovery() {
        const params = {
          billCode: this.temp.invenBillCode,
          remark: this.remark,
          billStatus: this.title === '通过' ? 2 : 3
        }
        if (this.aipType === 'get') {
          const res = await callarAudit(params)
          if (res.status === 200) {
            this.$message.success('操作成功')
            this.visible = false
            this.$emit('upDataTable')
          }
        } else {
          const res = await returnAudit(params)
          if (res.status === 200) {
            this.$message.success('操作成功')
            this.visible = false
            this.$emit('upDataTable')
          }
        }
      },
      reset() {
        this.remark = ''
        this.visible = false
      }
    }
  }
</script>

<style lang="scss" scoped>
  .title {
    width: 100%;
    margin-bottom: 15px;
    font-size: 16px;
    text-align: center;
  }

</style>
